using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ACME.Northwind.DataTransfer;
using ACME.Northwind.Service.Interfaces;
using ACME.Northwind.MockProxy.EventArgs;

namespace ACME.Northwind.MockProxy
{
	/// <summary>
	/// The service implementation for Employee object
	/// </summary>
	public partial class EmployeeService : IEmployeeService
	{
		#region IEmployeeService Members

		/// <summary>
		/// Run the mock for the select by the primary key
		/// </summary>
		public EmployeeDTO SelectByPrimaryKey(int employeeid)
		{
			EmployeePrimaryKeyEventArgs eventArgs = new EmployeePrimaryKeyEventArgs(employeeid);
			this.OnMockEmployeeSelectByPrimaryKey(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for select all
		/// </summary>
		public List<EmployeeDTO> RunSelect()
		{
			EmployeeRunSelectEventArgs eventArgs = new EmployeeRunSelectEventArgs();
			this.OnMockEmployeeRunSelect(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for select with LINQ
		/// </summary>
		public List<EmployeeDTO> RunSelect(string linq)
		{
			EmployeeRunSelectLINQEventArgs eventArgs = new EmployeeRunSelectLINQEventArgs(linq);
			this.OnMockEmployeeRunSelectLINQ(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Run the mock for paged select
		/// </summary>
		public PagedQueryResults<EmployeeDTO> RunSelect(int pageIndex, int pageSize, bool ascending, string sortColumn, string linq)
		{
			EmployeeRunSelectPagedEventArgs eventArgs = new EmployeeRunSelectPagedEventArgs(pageIndex, pageSize, ascending, sortColumn, linq);
			this.OnMockEmployeeRunSelectPaged(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Return a list of related Employee objects
		/// </summary>
		public List<EmployeeDTO> GetEmployeeList(EmployeeDTO item)
		{
			EmployeeDTOEventArgs eventArgs = new EmployeeDTOEventArgs(item);
			this.OnMockGetEmployeeList(eventArgs);
			List<EmployeeDTO> retval = new List<EmployeeDTO>();
			retval.AddRange(eventArgs.ReturnDTOList.Select(x => (EmployeeDTO)x));
			return retval;
		}

		/// <summary>
		/// Return a list of related EmployeeTerritory objects
		/// </summary>
		public List<EmployeeTerritoryDTO> GetEmployeeTerritoryList(EmployeeDTO item)
		{
			EmployeeDTOEventArgs eventArgs = new EmployeeDTOEventArgs(item);
			this.OnMockGetEmployeeTerritoryList(eventArgs);
			List<EmployeeTerritoryDTO> retval = new List<EmployeeTerritoryDTO>();
			retval.AddRange(eventArgs.ReturnDTOList.Select(x => (EmployeeTerritoryDTO)x));
			return retval;
		}

		/// <summary>
		/// Return a list of related Order objects
		/// </summary>
		public List<OrderDTO> GetOrderList(EmployeeDTO item)
		{
			EmployeeDTOEventArgs eventArgs = new EmployeeDTOEventArgs(item);
			this.OnMockGetOrderList(eventArgs);
			List<OrderDTO> retval = new List<OrderDTO>();
			retval.AddRange(eventArgs.ReturnDTOList.Select(x => (OrderDTO)x));
			return retval;
		}

		/// <summary>
		/// Return the related Employee item
		/// </summary>
		public EmployeeDTO GetEmployeeItem(EmployeeDTO item)
		{
			EmployeeDTO retval = new EmployeeDTO();
			EmployeeDTOEventArgs eventArgs = new EmployeeDTOEventArgs(item);
			this.OnMockGetEmployeeItem(eventArgs);
			retval = (EmployeeDTO)eventArgs.ReturnDTOItem;
			return retval;
		}

		/// <summary>
		/// Persists a single item
		/// </summary>
		public bool Persist(EmployeeDTO dto)
		{
			EmployeePersistEventArgs eventArgs = new EmployeePersistEventArgs(dto);
			this.OnMockEmployeePersist(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Persists a list
		/// </summary>
		public bool Persist(List<EmployeeDTO> list)
		{
			EmployeePersistEventArgs eventArgs = new EmployeePersistEventArgs(list);
			this.OnMockEmployeePersist(eventArgs);
			return eventArgs.ReturnValue;
		}

		/// <summary>
		/// Delete a single item
		/// </summary>
		public bool Delete(EmployeeDTO dto)
		{
			EmployeeDeleteEventArgs eventArgs = new EmployeeDeleteEventArgs(dto);
			this.OnMockEmployeeDelete(eventArgs);
			return eventArgs.ReturnValue;
		}

		#endregion

		#region Employee Events

		partial void GetSelectByPrimaryKey();

		/// <summary>
		/// The event for the SelectByPrimaryKey method
		/// </summary>
		public event EventHandler<EmployeePrimaryKeyEventArgs> MockEmployeeSelectByPrimaryKey;

		/// <summary>
		/// Raises the OnMockRegistrationCodeSelectByPrimaryKey event
		/// </summary>
		protected virtual void OnMockEmployeeSelectByPrimaryKey(EmployeePrimaryKeyEventArgs e)
		{
			if (this.MockEmployeeSelectByPrimaryKey != null)
				this.MockEmployeeSelectByPrimaryKey(this, e);
		}

		/// <summary>
		/// The event for the RunSelect method
		/// </summary>
		public event EventHandler<EmployeeRunSelectEventArgs> MockEmployeeRunSelect;

		/// <summary>
		/// Raises the OnMockRunSelect event
		/// </summary>
		protected virtual void OnMockEmployeeRunSelect(EmployeeRunSelectEventArgs e)
		{
			if (this.MockEmployeeRunSelect != null)
				this.MockEmployeeRunSelect(this, e);
		}

		/// <summary>
		/// The event for the RunSelectLINQ method
		/// </summary>
		public event EventHandler<EmployeeRunSelectLINQEventArgs> MockEmployeeRunSelectLINQ;

		/// <summary>
		/// The event for the OnMockRunSelectLINQ method
		/// </summary>
		protected virtual void OnMockEmployeeRunSelectLINQ(EmployeeRunSelectLINQEventArgs e)
		{
			if (this.MockEmployeeRunSelectLINQ != null)
				this.MockEmployeeRunSelectLINQ(this, e);
		}

		/// <summary>
		/// The event for the RunSelectPaged method
		/// </summary>
		public event EventHandler<EmployeeRunSelectPagedEventArgs> MockEmployeeRunSelectPaged;

		/// <summary>
		/// The event for the OnMockRunSelectPaged method
		/// </summary>
		protected virtual void OnMockEmployeeRunSelectPaged(EmployeeRunSelectPagedEventArgs e)
		{
			if (this.MockEmployeeRunSelectPaged != null)
				this.MockEmployeeRunSelectPaged(this, e);
		}

		/// <summary>
		/// The event for the GetEmployeeList method
		/// </summary>
		public event EventHandler<EmployeeDTOEventArgs> MockGetEmployeeList;

		/// <summary>
		/// The event for the OnMockGetEmployeeList method
		/// </summary>
		protected virtual void OnMockGetEmployeeList(EmployeeDTOEventArgs e)
		{
			if (this.MockGetEmployeeList != null)
				this.MockGetEmployeeList(this, e);
		}

		/// <summary>
		/// The event for the GetEmployeeTerritoryList method
		/// </summary>
		public event EventHandler<EmployeeDTOEventArgs> MockGetEmployeeTerritoryList;

		/// <summary>
		/// The event for the OnMockGetEmployeeTerritoryList method
		/// </summary>
		protected virtual void OnMockGetEmployeeTerritoryList(EmployeeDTOEventArgs e)
		{
			if (this.MockGetEmployeeTerritoryList != null)
				this.MockGetEmployeeTerritoryList(this, e);
		}

		/// <summary>
		/// The event for the GetOrderList method
		/// </summary>
		public event EventHandler<EmployeeDTOEventArgs> MockGetOrderList;

		/// <summary>
		/// The event for the OnMockGetOrderList method
		/// </summary>
		protected virtual void OnMockGetOrderList(EmployeeDTOEventArgs e)
		{
			if (this.MockGetOrderList != null)
				this.MockGetOrderList(this, e);
		}

		/// <summary>
		/// The event for the GetEmployeeItem method
		/// </summary>
		public event EventHandler<EmployeeDTOEventArgs> MockGetEmployeeItem;

		/// <summary>
		/// The event for the OnMockGetEmployeeItem method
		/// </summary>
		protected virtual void OnMockGetEmployeeItem(EmployeeDTOEventArgs e)
		{
			if (this.MockGetEmployeeItem != null)
				this.MockGetEmployeeItem(this, e);
		}

		/// <summary>
		/// The event for the Persist method
		/// </summary>
		public event EventHandler<EmployeePersistEventArgs> MockEmployeePersist;

		/// <summary>
		/// Raises the OnMockPersist event
		/// </summary>
		protected virtual void OnMockEmployeePersist(EmployeePersistEventArgs e)
		{
			if (this.MockEmployeePersist != null)
				this.MockEmployeePersist(this, e);
		}

		/// <summary>
		/// The event for the Delete method
		/// </summary>
		public event EventHandler<EmployeeDeleteEventArgs> MockEmployeeDelete;

		/// <summary>
		/// Raises the OnMockDelete event
		/// </summary>
		protected virtual void OnMockEmployeeDelete(EmployeeDeleteEventArgs e)
		{
			if (this.MockEmployeeDelete != null)
				this.MockEmployeeDelete(this, e);
		}

		#endregion

	}
}
